<template>
  <div class="demo">
    <h1>学校名称：{{schoolName}}</h1>
    <h1>学校地址：{{schoolAddress}}</h1>

    <button @click="copy">复制文本</button>
  </div>
</template>

<script>
export default {
  name: 'School',

  data(){
    return {
      schoolName: '清华大学',
      schoolAddress: '北京',
      text: "哈哈哈哈哈"
    }
  },
  methods: {
    copy() {
      navigator.clipboard.writeText(this.text).then(() => {
        console.log('复制成功')
      })
          .catch(e=>{
            console.log('复制失败',e)
          })
    }
  }
}

</script>

<style>
/*组件的样式*/

.demo {
  color: orange;
}
</style>